<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>

  <div id="app"></div>

  <script>

    //全局混入
    Vue.mixin({
      beforeCreate() {
        console.log('from mixin beforeCreate')
      },
      created() {
        console.log('from mixin created')
      },
      data() {
        return {
          username: 'xiaoming'
        }
      },
      methods: {
        getusername() {
          return this.username;
        }
      },
    })

    var vm = new Vue({
      el: "#app",
      data: {
        username: 'hanye',
        age: 20
      },
      methods: {
        // getusername() {
        //   return this.username;
        // }
      },
      beforeCreate() {
        console.log('beforeCreate')
      },
      created() {
        console.log('created')
        // console.log(this.username, this.age)
      },
      mounted() {
        console.log(this.getusername())
      }
    })


  </script>

</body>

</html>